home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / SourceCode / MiniExamples / CellScrollView / FooCell.m < prev    next >
Encoding:
Text File  |  1991-09-10  |  1.4 KB  |  74 lines

  1. /*
  2.  * You may freely copy, distribute, and reuse the code in this example.
  3.  * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
  4.  * fitness for any particular use.
  5.  */
  6.  
  7.  
  8. #import "FooCell.h"
  9. #import "FooObject.h"
  10. #import <appkit/Text.h>
  11. #import <dpsclient/psops.h>
  12. #import <objc/hashtable.h>
  13. #import <stdlib.h>
  14. #import <stdio.h>
  15.  
  16. #define FIELD1_LMARGIN 4.0
  17. #define FIELD2_LMARGIN 54.0
  18.  
  19. @implementation FooCell
  20.  
  21. - init
  22. {
  23.   [super init];
  24.   [self setType:NX_TEXTCELL];
  25.   return self;
  26. }
  27.  
  28. - fooObject
  29. {
  30.   return fooObject;
  31. }
  32.  
  33. - setFooObject:anObject
  34. {
  35.   fooObject = anObject;
  36.   return self;
  37. }
  38.  
  39. - setFont:fontObj
  40. {
  41.   [super setFont:fontObj];
  42.   /*
  43.    * save this info so we don't have to look it up every time we draw
  44.    * Note:  support for a TextCell is a font object
  45.    */
  46.   NXTextFontInfo(support, &ascender, &descender, &lineHeight);
  47.   return self;
  48. }    
  49.  
  50. - drawInside:(const NXRect *)cellFrame inView:controlView
  51. {
  52.   char        buf[100];
  53.   NXCoord    baseX, baseY;
  54.  
  55.   baseX = NX_X(cellFrame);
  56.   baseY = NX_Y(cellFrame) + lineHeight - descender;
  57.      
  58.   /* erase the cell */
  59.   PSsetgray((cFlags1.state || cFlags1.highlighted) ? NX_WHITE : NX_LTGRAY);
  60.   NXRectFill(cellFrame);
  61.  
  62.   PSsetgray(NX_BLACK);
  63.   /* draw the start, duration, and mark name in black */
  64.   PSmoveto(baseX + FIELD1_LMARGIN, baseY);
  65.   sprintf(buf,"%d",[fooObject intValue]);
  66.   PSshow(buf);
  67.   PSmoveto(baseX + FIELD2_LMARGIN, baseY);
  68.   PSshow("xyzzy");
  69.  
  70.   return self;
  71. }
  72.  
  73. @end
  74.